/**
 * @description 分解类型
 */

import { giveTypeAnswer } from './giveTypeAnswer'

export type UnionTypeNodeType = {
  type: string
  types: UnionTypeNodeType[]
}
// 分解联合类型
export function breakDownUnionType(type: UnionTypeNodeType): string {
  const unionTypeResult = type.types.map(typeItem => giveTypeAnswer(typeItem.type)).join(' | ')
  return unionTypeResult
}
/**
 * @description 交叉类型
 */
type typeAnnotation = {
  type: string
  typeAnnotation: typeAnnotation
}
export type IntersectionType = {
  type: string
  types: {
    type: string
    members?: {
      type: string
      key: {
        name: string
      }
      typeAnnotation: typeAnnotation
    }[]
  }[]
}
// TODO: 分解交叉类型 未完成
export function breakDownIntersectionType(type: IntersectionType) {
  type.types.map(typeItem => {
    // @ts-ignore
    console.log(typeItem?.members?.[0].typeAnnotation.typeAnnotation)
  })
}
